import java.util.ArrayList;
import java.util.Scanner;

public class MathRadom {
    /**
     * 往数组中随机填入1-100之间的整数，然后统计并输出其中大于50与小于等于50的百分比
     * @param args
     */

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        ArrayList arrayList = new ArrayList();
        int sum_max=0, sum_min=0;   //统计大于50 小于等于50的个数

        System.out.println("输入n个元素:");
        int n = scanner.nextInt();

        for (int i = 0; i < n; i++) {
            double temp = Math.random()*100;
            arrayList.add(temp);
            if (temp > 50)
                sum_max++;
            else
                sum_min++;
        }
        double result_max = 1.0 * sum_max / n * 100;
        double result_min = 1.0 * sum_min / n * 100;
        System.out.printf("大于50: %.2f%% 小于等于50: %.2f%%", result_max, result_min);
    }
}

